package com.lt.flashcard.model.entity;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.bson.types.ObjectId;

import com.google.code.morphia.annotations.Entity;
import com.google.code.morphia.annotations.Id;

/**
 * Add coin history, when user adding new coin via payment
 * @author ocsen
 *
 */
@Entity("addcoinhistory")
public class AddCoinHistory {

	@Id
	private ObjectId id;
	
	private Date created = new Date();
	
	private Long userid; //Adding for who
	
	private int amount = 0; //The payment amount
	
	private int coin = 0; //Equivalent coin
	
	private int status = 0; //The status
	public static final int STATUS_PAYMENT = 0;
	public static final int STATUS_COMPLETE = 1;
	public static final int STATUS_ERROR = 2;
	public static final int STATUS_CANCEL = 3;
	
	private int paymenttype = 0;
	public static final int TYPE_NGANLUONG = 0;
	public static final int TYPE_CARD = 1;
	public static final int TYPE_OTHER = 2;
	
	private String history = "";
	
	//Store processed phone card info to do statistic
	private List<PhoneCardResponse> cardResponse = new ArrayList<PhoneCardResponse>();

	public ObjectId getId() {
		return id;
	}

	public void setId(ObjectId id) {
		this.id = id;
	}

	public Date getCreated() {
		return created;
	}

	public void setCreated(Date created) {
		this.created = created;
	}

	public Long getUserid() {
		return userid;
	}

	public void setUserid(Long userid) {
		this.userid = userid;
	}

	public int getAmount() {
		return amount;
	}

	public void setAmount(int amount) {
		this.amount = amount;
	}

	public int getCoin() {
		return coin;
	}

	public void setCoin(int coin) {
		this.coin = coin;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public int getPaymenttype() {
		return paymenttype;
	}

	public void setPaymenttype(int paymenttype) {
		this.paymenttype = paymenttype;
	}

	public String getHistory() {
		return history;
	}

	public void setHistory(String history) {
		this.history = history;
	}
	
	/**
	 * Append a history
	 * @param paymethistory
	 */
	public void addHistory(String history) {
		this.history = this.history.concat("\n" + history);
	}

	/**
	 * @return the cardResponse
	 */
	public List<PhoneCardResponse> getCardResponse() {
		return cardResponse;
	}

	/**
	 * @param cardResponse the cardResponse to set
	 */
	public void setCardResponse(List<PhoneCardResponse> cardResponse) {
		this.cardResponse = cardResponse;
	}
	
	public void addCardResponse(PhoneCardResponse cardresponse) {
		this.cardResponse.add(cardresponse);
	}
}
